var BASE_URL = 'http://116.62.228.37:8200/';

var ltNetwork = (function(){
	var get = function(url,param,successfn,errorfn){
		mui.ajax({
		 	url:url,
			data:param,
			dataType:'jsonp',
			type:'get',	              
			success:function(res){
				//服务器返回响应，根据响应结果，分析是否登录成功；
				var res = JSON.parse(res);		//字符串转换成json
				successfn(res);
			},
			error:function(xhr,type,errorThrown){
				//异常处理；
				errorfn(type)
			}
		})
	};
	var post = function(url,param,successfn,errorfn){
		mui.ajax({
		 	url:url,
			data:param,
			dataType:'jsonp',
			type:'post',	              
			success:function(res){
				//服务器返回响应，根据响应结果，分析是否登录成功；
				successfn(res);
			},
			error:function(xhr,type,errorThrown){
				//异常处理；
				errorfn(type)
			}
		})
	};
	var tokenPost = function(url,param,authorization,successfn,errorfn){
		$.ajax({
			type:"post",
			url:url,
			async:true,
			data:param,
			crossDomain: true,
			dataType: "json",
			headers:{
				'authorization':authorization
			},
			success:function(res){
				successfn(res);
			},
			error:function(xhr,type,msg){
				errorfn(msg);
			}
		});
	};
	var tokenGet = function(url,param,authorization,successfn,errorfn){
		$.ajax({
			type:"get",
			url:url,
			async:true,
			data:param,
			headers:{
				'authorization':authorization
			},
			success:function(res){
				successfn(res);
			},
			error:function(xhr,type,msg){
				errorfn(msg);
			}
		});
	}
	var tokenDelete = function(url,param,authorization,successfn,errorfn){
		$.ajax({
			type:"DELETE",
			url:url,
			async:true,
			data:param,
			headers:{
				'authorization':authorization
			},
			success:function(res){
				successfn(res);
			},
			error:function(xhr,type,msg){
				errorfn(msg);
			}
		});
	}
	return{
		get:get,
		post:post,
		tokenPost:tokenPost,
		tokenGet:tokenGet,
		tokenDelete:tokenDelete
	}
})();
